﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Common;
using Persistence.Dao;
using Domain;
using Persistence;
namespace web.manage
{
    public partial class leaveword_operate : System.Web.UI.Page
    {
        int id = DNTRequest.GetQueryInt("id", 0);
        protected Leaveword entity_Leaveword = new Leaveword();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (id > 0)
                {
                    entity_Leaveword = Singleton<LeavewordDao>.Instance.GetModel(id);
                    if (entity_Leaveword != null)
                    {
                        ViewState["entity_Leaveword"] = entity_Leaveword;
                        txt_Leaveword_replyContent.Value = entity_Leaveword.replyContent;
                    }
                }
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Leaveword entity_Leaveword = new Leaveword();
            if (id > 0 && ViewState["entity_Leaveword"] != null)
            {
                entity_Leaveword = (Leaveword)ViewState["entity_Leaveword"];
            }
           
            entity_Leaveword.replyContent = txt_Leaveword_replyContent.Value.Trim();
            entity_Leaveword.replyTime = DateTime.Now;

            bool bResult = false;
            if (id > 0)
            {
                bResult = Singleton<LeavewordDao>.Instance.Update(entity_Leaveword);
            }
            if (bResult)
            {
                Message.alertAndClose("操作成功");
            }
            else
            {
                Message.alert("操作失败，请检查您的数据");
            }
        }
    }
}
